<%@ page language="java" contentType="text/html; charset=UTF8" pageEncoding="UTF8"%>
<%@ page import="java.util.*" %>
<%@ page import="bcnet.service.PriceHistoryService" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%
	String code = request.getParameter("code");
	String priceDateString = request.getParameter("priceDate");
	String closePriceString = request.getParameter("closePrice");
	String volumeString = request.getParameter("volume");
	String lowPriceString = request.getParameter("lowPrice");
	String highPriceString = request.getParameter("highPrice");
	
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
	
	
	if(code == null){
		
	}
	else {
		Date priceDate = sdf.parse(priceDateString);
		double closePrice = Double.parseDouble(closePriceString);
		long volume = Long.parseLong(volumeString);
		double lowPrice = Double.parseDouble(lowPriceString);
		double highPrice = Double.parseDouble(highPriceString);
		PriceHistoryService priceHistoryService = new PriceHistoryService();
		priceHistoryService.addPriceHistory(code, priceDate, closePrice, volume, lowPrice, highPrice);
	}

%>

<form action="addPrice.jsp" method="post">
 		<label style="font-size:22px;">Add price</label>
 		<br/>
        <label for="code">Code:</label>  
        <input type="text" id="code" name="code" placeholder="code" required autofocus >
        <br/>
        <label for="code">Price Date:</label>  
        <input type="text" id="priceDate" name="priceDate" placeholder="priceDate" required >
        <br/>
        <label for="code">Close Price:</label>  
        <input type="text" id="closePrice" name="closePrice" placeholder="closePrice" required >
		
        <label for="code">Volume:</label>  
        <input type="text" id="volume" name="volume" placeholder="volume" required >

        <label for="code">Low Price:</label>  
        <input type="text" id="lowPrice" name="lowPrice" placeholder="lowPrice" required >
		
        <label for="code">High Price:</label>  
        <input type="text" id="highPrice" name="highPrice" placeholder="highPrice" required >
		<button type="submit">Update</button>  		
	 </form>  
